<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>phonegap_device_network_notification01</title>
<link href="../jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css"/>
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="../cordova.js" type="text/javascript"></script>
 <style>
    #supportedMode{
        width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
    }
    #message{
        width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
    }
    #audiocontainer{
        width: 288px; height: 100px; position:relative;border:1px solid #b8b8b8;
    }
    </style>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){                      
         document.addEventListener("deviceready",onDeviceReady,false); 
	  
	 });
    function onDeviceReady(){ 
          $(".captureVideoBtn").click(function(){
          	  navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 2});
          })   
    }    
   
    
    function captureSuccess(mediaFiles) { 
        var i, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            var fullPath= mediaFiles[i].fullPath;
            
  			var name= mediaFiles[i].name  	      
            console.log('第'+i+'个音频');
  			console.log('fullPath-->'+fullPath);
  			console.log('name-->'+name);
  			console.log("type--->" + mediaFiles[i].type);
 			console.log("lastModifiedDate--->" + mediaFiles[i].lastModifiedDate);
 			console.log("size--->" + mediaFiles[i].size);
 			
 			mediaFiles[i].getFormatData(onSuccess,onError);
 			function onSuccess(fileData){
 					console.log("codecs---->" + fileData.codecs);
 					console.log("bitrate--->" + fileData.bitrate);
 					console.log("height---->" + fileData.height);
 					console.log("width---->" + fileData.width);
 					console.log("duration---->" + fileData.duration);
 			
 			}
 			function onError(err){
 				console.log("失败"+err);
 			}
 			
        }       
    }
    
    // Called if something bad happens.
    // 
    function captureError(error) {               
        if (error.code == CaptureError.CAPTURE_INTERNAL_ERROR){
            navigator.notification.alert("CaptureError.CAPTURE_INTERNAL_ERROR");
        }
        else if (error.code == CaptureError.CAPTURE_APPLICATION_BUSY){
            navigator.notification.alert("CaptureError.CAPTURE_APPLICATION_BUSY");
        }
        else if (error.code == CaptureError.CAPTURE_INVALID_ARGUMENT){
            navigator.notification.alert("CaptureError.CAPTURE_INVALID_ARGUMENT");
        }
        else if (error.code == CaptureError.CAPTURE_NO_MEDIA_FILES){
            navigator.notification.alert("CaptureError.CAPTURE_NO_MEDIA_FILES");
        }
        else if (error.code == CaptureError.CAPTURE_NOT_SUPPORTED){
            navigator.notification.alert("CaptureError.CAPTURE_NOT_SUPPORTED");
        }                                
    }

    </script>
</head> 
<body>
<div data-role="page">
		<div data-role="header">
			<h1>phonegap100.com</h1>
		</div>
		 <div data-role="content" >
            <a data-role="button" class="captureVideoBtn" >Capture Video</a>                 
            <div id="videocontainer"></div>
            <div id="message"></div>       
        </div>
		<div data-role="footer">
			<h4>phonegap中文网</h4>
		</div>
</div>

</body>
</html>
